<template>
  <van-popup v-model="showDialog">
    <div class="dialog-wrap">
      <div class="title">{{ title }}</div>
      <div class="dialog-content">
        <slot name="content"></slot>
      </div>
      <div class="footer">
        <div class="btn left" @click="handleClose">{{ cancelText }}</div>
        <div class="btn right" @click="handleSure">{{ okText }}</div>
      </div>
    </div>
  </van-popup>
</template>

<script>
export default {
  name: 'confirmPopup',
  props: {
    title: {
      type: String,
      default: '标题'
    },
    cancelText: {
      type: String,
      default: '取消'
    },
    okText: {
      type: String,
      default: '确定'
    }
  },
  data() {
    return {
      showDialog: false
    };
  },
  methods: {
    handleClose() {
      this.showDialog = false;
      this.$emit('onCancel');
    },
    handleSure() {
      this.$emit('onOk');
    }
  }
};
</script>

<style lang="scss" scoped>
.dialog-wrap {
  width: 5.5rem;
  background-color: #fff;
  border-radius: 0.08rem;
  font-size: 0.28rem;
  padding-top: 0.44rem;

  .title {
    font-size: 0.32rem;
    color: #333;
    text-align: center;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    margin-bottom: 0.2rem;
  }

  .dialog-content {
    width: 4.42rem;
    margin: 0 auto;
    font-size: 0.28rem;
    color: #666;
    font-family: PingFangSC-Regular;
    padding-bottom: 0.4rem;
  }

  .footer {
    height: 0.9rem;
    display: flex;
    border-top: 1px solid #eeeeee;
    .btn {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
      font-weight: 400;
      font-size: 0.28rem;
      border-right: 1px solid #eee;
      &:last-child {
        border-right: none;
      }
    }

    .left {
      color: #666;
    }

    .right {
      color: #333;
      font-weight: 500;
      font-family: PingFangSC-Medium;
    }
  }
}

.van-popup {
  background-color: transparent;
  border-radius: 0;
}
</style>
